#!/bin/bash

echo "========================================"
echo " 订单管理系统示例 - 启动脚本"
echo " Enums Spring Boot Starter Demo"
echo "========================================"
echo

echo "正在检查Java环境..."
if ! command -v java &> /dev/null; then
    echo "错误：未找到Java环境，请确保已安装Java 8或更高版本"
    exit 1
fi

echo "正在检查Maven环境..."
if ! command -v mvn &> /dev/null; then
    echo "错误：未找到Maven环境，请确保已安装Maven 3.6或更高版本"
    exit 1
fi

echo
echo "正在编译项目..."
mvn clean compile -q
if [ $? -ne 0 ]; then
    echo "编译失败，请检查代码是否有错误"
    exit 1
fi

echo "编译成功！正在启动应用..."
echo
echo "========================================"
echo " 应用启动中，请稍等..."
echo "========================================"
echo " 访问地址："
echo " - Swagger UI: http://localhost:8080/swagger-ui/"
echo " - 枚举码表API: http://localhost:8080/api/enums"
echo " - H2数据库: http://localhost:8080/h2-console"
echo "========================================"
echo

mvn spring-boot:run
